<template>
	流程信息
	<el-form :model="step" label-width="120px">

		<el-form-item label="标题">
			<el-input v-model="step.stepTitle" />
		</el-form-item>
		
		<el-form-item label="处理人">
			<el-select v-model="step.stepProcessorid" placeholder="please select your zone">
				<el-option v-for="(item,index) in users" :label="item.userName" :value="item.userId" @click="handleChange(index)" />
			</el-select>
		</el-form-item>

		<el-form-item label="处理意见">
			<el-input v-model="step.stepOpinions" :rows="5" type="textarea" placeholder="Please input" />
		</el-form-item>

		费用信息

		<el-form-item label="种类">
			<el-select v-model="step.feeKind" placeholder="please select your zone">
				<el-option label="支出" value="支出" />
				<el-option label="收入" value="收入" />
			</el-select>
		</el-form-item>


		<el-form-item label="金额">
			<el-input v-model="step.feeCost" />
		</el-form-item>

		<el-form-item label="费用备注">
			<el-input v-model="step.feeDetail" :rows="5" type="textarea" placeholder="Please input" />
		</el-form-item>

		<el-button type="primary" @click="onSubmit">提交</el-button>

	</el-form>
</template>

<script>
import qs from 'qs'
	export default {
		data() {
			return {
				user: {

				},
				step: {
					stepTitle: '',
					creatorId: this.$store.state.user.userId,
					creatorName:this.$store.state.user.userName,
					stepProcessorid: null,
					stepProcessor:'',
					stepOpinions: '',
					feeKind: '',
					feeDetail: '',
					feeCost: null,
					stepKind:'费用申请',
					stepIsend:'否',
				},
				users: [],

			}
		},
		methods: {
			onSubmit() {
				console.log(this.step)
				let that = this
				let str = qs.stringify(this.step)
				this.$axios.get("http://localhost:8080/step/insertfee?" + str).then(function(res) {
					console.log(res);
					if(res.data==1){
						alert("提交成功")
						that.$router.go(0);
					}
				})
			},
			dpmchange() {
				this.post.postDepartment = this.step.permanageDepartment
				let that = this
				let str = qs.stringify(this.post)
				console.log(this.post)
				this.$axios.get("http://localhost:8080/post/search?" + str).then(function(res) {
					console.log(res);
					that.posts = res.data;
					console.log(that.posts);
				})
			},
			getAllusers() {
				let that = this
				let str = qs.stringify(this.user)
				this.$axios.get("http://localhost:8080/user/search?" + str).then(function(res) {
					console.log(res);
					that.users = res.data;
					console.log(that.users);
				})
			},
			handleChange(index) {
				this.step.stepProcessor=this.users[index].userName
			}
		},
		created() {
			this.getAllusers()
		}

	}
</script>
<style>
</style>>
